package kr.couponplay.android.activity.message;

import kr.couponplay.android.domain.deal.Provider;
import kr.couponplay.android.domain.message.MessageList;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentStatePagerAdapter;

public class MessageListViewPagerAdapter extends FragmentStatePagerAdapter {
	private MessageActivity activity;
	private MessageList messageList;
	
	public MessageListViewPagerAdapter(MessageActivity activity, MessageList messageList) {
		super(activity.getSupportFragmentManager());
        this.activity = activity;
        this.messageList = messageList;
    }

	@Override
	public Fragment getItem(int position) {
		Provider provider = MessageSubMenuHelper.get(position).getProvider();
		return MessageListFragment.newInstance(activity, position, messageList.getMessageItems(provider));
    }
	
	@Override
	public int getItemPosition(Object item) {
		MessageListFragment fragment = (MessageListFragment)item;
		return fragment.getPosition();
    }
	
	@Override
	public int getCount() {
		return MessageSubMenuHelper.getMessageBoxes().size();
	}
}
